﻿<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mwc" Namespace="MySoft.WebControls" Assembly="MySoft.WebControls" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Cwjk_SelectObjectDataForKJKM.aspx.vb" Inherits="PubProject.Cwjk_SelectObjectDataForKJKM" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>选择业务数据</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<!-- Global -->
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<!-- Menu -->
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<script language="javascript" src="/_nav/menu.js"></script>
		<!-- Grid -->
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
		<!-- Form -->
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<!-- Tab -->
		<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
		<!-- workflow -->
		<script language="javascript" src="/MyWorkflow/workflow.js"></script>
		<!-- Utility-->
		<script language="javascript" src="/_controls/util/util.js"></script>
		<!-- Public -->
		<script language="javascript" src="Xmjd/JS/Public.js"></script>
		<!-- Public -->
		<script language="javascript" src="/PubProject/JS/Public.js"></script>
		<style>
			.scrollColThead {
			position: relative; 
			top: expression(this.parentElement.parentElement.parentElement.scrollTop);
			z-index:2;
			}
			NOBR	{ OVERFLOW: hidden; WIDTH: 100%; TEXT-OVERFLOW: ellipsis }			
		</style>
		<script language="javascript">
			//在线帮助
		　　//var _MyHelpfile = "";	
		
			// 界面初始化
			function window.onload()
			{
				if ( document.all("__ObjectType") && document.all("__ObjectType").value != "" )
				{
				    var sObjectType = document.all("__ObjectType").value;

				    //设置界面标题
				    document.title  = "选择" + sObjectType;
				    //设置列表标题
				    appGridMenu.cells[0].innerHTML = "<B>"+ sObjectType +"列表";
				    //设置系统业务数据
				    document.getElementById("inputObjectType").value = sObjectType;
				    
				    var oTr = document.all("HeaderTableID").rows[0];
				    
				    switch (sObjectType)
			        {
			            case "入账银行":
					        oTr.cells[2].innerText = "入账银行名称";
					        break;
				        case "票据类型":
					        oTr.cells[2].innerText = "票据类型名称";
					        break;
				        case "项目名称 票据类型":
					        oTr.cells[2].innerText = "项目名称+票据类型";
					        appGridMenu.cells[0].innerHTML = "<B>项目名称+票据类型列表";
					        document.getElementById("inputObjectType").value = "项目名称+票据类型";
					        document.title  = "选择项目名称+票据类型";
					        break;
				        case "一级产品类型 票据类型":
				            oTr.cells[2].innerText = "一级产品类型+票据类型";
				            appGridMenu.cells[0].innerHTML = "<B>一级产品类型+票据类型列表";
				            document.getElementById("inputObjectType").value = "一级产品类型+票据类型";
				            document.title  = "一级产品类型+票据类型";
					        break;        			
				        case "产品":
					        oTr.cells[2].innerText = "产品名称";
					        break;
				        case "款项类型":
					        oTr.cells[2].innerText = "款项类型名称";
					        break;
				        case "付款银行":
				            oTr.cells[2].innerText = "付款银行名称";
					        break;
					    default:
					        oTr.cells[2].innerText = "业务数据名称";
					        break;
			        }
			        
			        if (document.all("__SelectObject") && document.all("__SelectObject").value != "")
				    {
				        var sSelectObject = document.all("__SelectObject").value.toLowerCase();
				        var isCheckGUID = false;
				        var sCheckValue = "";
				        var oTable = document.all("TableID");

				        if (sObjectType == "产品")
				        {
				            isCheckGUID = true;
				        }
				        
				        if (isCheckGUID)
				        {
				            for( var i = 0; i < oTable.rows.length; i++)
			                {
			                    sCheckValue = oTable.rows[i].oid;

			                    if ( sSelectObject.indexOf(sCheckValue.toLowerCase()) >= 0 )
			                    {
				                    oTable.rows[i].cells[0].children[0].checked = true;
				                }
			                }
			            }
			            else
			            {
			                var sSelectObjectList = sSelectObject.split(',');
			                
			                for( var i = 0; i < oTable.rows.length; i++)
			                {
			                    sCheckValue = oTable.rows[i].ObjectName.toLowerCase();

			                    if (sObjectType=="项目名称 票据类型" || sObjectType=="一级产品类型 票据类型")
			                    {
			                        sCheckValue = sCheckValue.replace("+", " ");
			                    }
				                
				                for ( var j = 0; j < sSelectObjectList.length; j++ )
			                    {
			                        if ( sSelectObjectList[j] == sCheckValue )
			                        {
				                        oTable.rows[i].cells[0].children[0].checked = true;
				                    }
				                }
			                }
			            }
				    }
				}
			}
			
			// 全选、取消全选
			function doCheckAll(obj)
			{
				var blchecked = obj.checked;
				var oTable = document.all("TableID");
				
				for( var i = 0; i < oTable.rows.length; i++)
				{
					oTable.rows[i].cells[0].children[0].checked = blchecked;
				}
			}

			//
			function Ok()
			{
				//
				var sObjectName = "";
				var sObjectGUID = "";
	
				var oTable = document.all("TableID");
				
				if (oTable.rows.length > 0)
				{
					for( var i = 0; i < oTable.rows.length; i++)		
					{
						if ( oTable.rows[i].cells[0].children[0].checked == true )
						{
							 if(oTable.rows[i].ObjectName.indexOf(",") != -1)
							 {
							    alert("选择项的名称不允许包含逗号(,),请重新选择！");
							    oTable.rows[i].click();
							    return;
							 }
							 sObjectGUID += oTable.rows[i].oid + ",";
							 sObjectName += oTable.rows[i].ObjectName + ",";
						}
					}
					sObjectGUID = sObjectGUID.substr(0, sObjectGUID.length - 1);
					sObjectName = sObjectName.substr(0, sObjectName.length - 1);					
				}
				
				if (sObjectGUID=="")
				{
				    var sObjectType = "业务数据";
				    
				    if (document.all("__ObjectType"))
				    {
				        sObjectType = document.all("__ObjectType").value;
				    }
				    
				    if (sObjectType=="项目名称 票据类型")
			        {
				        alert("请选择项目名称+票据类型！");
				    }
				    else if (sObjectType=="一级产品类型 票据类型")
				    {
				        alert("请选择一级产品类型+票据类型！");
				    }
				    else
				    {
				        alert("请选择" + sObjectType + "！");
				    }
				    
				    return;
				}
				
				parent.window.returnValue = new Array(sObjectName,sObjectGUID);
				parent.window.close();				
			}
			
			//清空按钮
			function SelectCancel()
			{
				parent.window.returnValue = new Array("","");
				parent.window.close();
			}
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout" style="PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-BOTTOM: 15px; PADDING-TOP: 15px">
		<form id="Form1" runat="server">
			<asp:TextBox id="txtCwztGUID" style="DISPLAY: none" runat="server"></asp:TextBox><asp:TextBox id="txtObjectType" style="DISPLAY: none" runat="server"></asp:TextBox>
		<table style="FONT-SIZE: 9pt" height="100%" cellSpacing="0" cellPadding="0" width="100%">
		    <tr height="1">
				<td>
					<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" style="padding-bottom: 5px;">
					    <tr>
					        <td style="width:80px">系统业务数据</td>
					        <td><input id="inputObjectType" type="text" value="" disabled="disabled" readonly="readonly" style="width:100%;" /></td>
					    </tr>
					</table>
				</td>
			</tr>
			<tr height="1">
				<td>
					<mnu:AppGridMenu id="appGridMenu" runat="server" />
				</td>
			</tr>
			<tr>
				<td valign="top">
					<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" style="BACKGROUND-COLOR: white;table-layout:fixed">
					    <TBODY>
					    <tr valign="top">
						    <td>
						        <table id="HeaderTableID" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; padding-top:0px;" cellpadding="0" cellspacing="0" width="100%">
						            <colgroup id="TableColsHeader">
						                <col width="40">
						                <col width="2">
						                <col>
						                <col width="2">
					                </colgroup>
						            <tr class="scrollColThead" id="trHeader" pagesize="" align="center" style="CURSOR:hand; height:20px;">
						                <td align="center" class="gridBar"><input type="checkbox" id="chkAll" title="选择本页所有记录" onclick="doCheckAll(this)"></td>
						                <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
						                <td class="gridBar"><nobr>业务数据名称</nobr></td>
						                <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
					                </tr>
						        </table>
							    <div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 94%">
							    <!-- repeater -->
						            <mwc:repeater id="Repeater1" runat="server" SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">' SortSignASC='<img src="/_imgs/ico_arrow_u.gif">' EnablePager="false">
							            <HeaderTemplate>
							                <table id="TableID" cellpadding="0" cellspacing="0" border="0" style="table-layout:fixed">
								                <colgroup id="TableCols">
									                <col width="40">
									                <col width="2">
									                <col>
									                <col width="2">
								                </colgroup>
								                <TBODY>
							            </HeaderTemplate>
							            <ItemTemplate>
								            <tr style="CURSOR: hand; height:24px;" oid='<%# DataBinder.Eval(Container.DataItem, "ObjectGUID") %>' ObjectName='<%# DataBinder.Eval(Container.DataItem, "ObjectName") %>'>
									            <td class="gridBorder" align="center" colspan="2"><input type="checkbox" id='chk_Plan'></td>
									            <td class="gridBorder" align="left" colspan="2" title='<%# DataBinder.Eval(Container.DataItem, "ObjectName") %>'><nobr><%#DataBinder.Eval(Container.DataItem, "ObjectName")%></nobr></td>
								            </tr>
							            </ItemTemplate>
							            <FooterTemplate>
							                    </TBODY>
						                    </table>
		                                </FooterTemplate>
		                             </mwc:repeater>
		                         <!-- repeater --> 
		                     </div>
				            </td>
			              </tr>
			           </TBODY>
		            </table>		
				</td>
			</tr>
			<tr height="40">
				<td class="buttons" align="right">
				    <button onclick="SelectCancel()" id="btnCancel" type="button">清 空</button>&nbsp;&nbsp;
					<button onclick="Ok()" id="btnOk" type="button">确 定</button>&nbsp;&nbsp;
					<button onclick="parent.window.close();" type="button">取 消</button>
				</td>
			</tr>			
		</table>
		</form>
	</body>
</HTML>